<template>
  <div class="content">
    <dc-header :page-to="backUrl" :icon="'icon-header-back'"
               :title="'记账设置'"></dc-header>
    <div class="head-top">
      <mt-cell :to="'/accountMethod/'+accountSet.accountMode + '/'+backType" title="记账方式选择" class="mt20" isLink>
        <span class="right-link">
          <span class="gray">{{accountSet.accountMode === 1 ? '简易版' : '专业版'}}</span>
        </span>
      </mt-cell>
      <mt-cell :to="'/rawCostCount/'+accountSet.costingMode+'/'+accountSet.profitRate +'/'+accountSet.accountMode+'/'+ backType"
               title="原料成本计算方式" class="no-border mt20" isLink>
        <span class="right-link">
          <span class="gray">{{costingName}}</span>
        </span>
      </mt-cell>
      <mt-cell v-if="accountSet.accountMode === 1" title="支出类别设置" class="mt20 no-border account-type-gray"
               isLink></mt-cell>
      <mt-cell v-if="accountSet.accountMode === 1" title="收入类别设置" class="account-type-gray" isLink></mt-cell>
      <!--专业版-->
      <mt-cell v-if="accountSet.accountMode === 2" :to="'/accountTypeSet' + '/' + 2" title="支出类别设置"
               class="mt20 no-border" isLink></mt-cell>
      <mt-cell v-if="accountSet.accountMode === 2" :to="'/accountTypeSet' + '/' + 1" title="收入类别设置" isLink></mt-cell>
    </div>
  </div>
</template>
<script>
  import header from '@/common/plugins/header';
  import api from '../../../common/api/account';

  export default {
    data () {
      return {
        accountSet: {
          accountMode: 1, //1表示保存选择简易版，2表示专业版
          costingMode: 3  //1：云库存（暂不支持）2：毛利率；3：手动记账
        },
        backType: 1,  //表示返回的地址，1表示回到简易版或者专业版，2表示回到我的模块
        backUrl: '',
        costingName: '云库存'
      };
    },
    created () {
      if (this.$route.params.code) {
        this.backType = this.$route.params.code;
      };
      //记账设置中获取原料成本计算方式和记账方式
      api.getAccountSet({}).then(res => {
        this.accountSet = res;
        if (this.accountSet.costingMode === 1) {
          this.costingName = '云库存';
        } else if (this.accountSet.costingMode === 2) {
          this.costingName = '毛利率';
        } else if (this.accountSet.costingMode === 3) {
          this.costingName = '手动记账';
        };
        if (this.$route.params.code === '1') {
          if (this.accountSet.accountMode === 1) {
            this.backUrl = '/simAccountTool';
          } else {
            this.backUrl = '/proAccountTool';
          }
        } else {
          this.backUrl = '/personal';
        };
      });
    },
    components: {
      'dc-header': header
    },
    methods: {
      _next () {
      }
    }
  };
</script>
<style lang="scss" scoped>
  @import "../../../assets/css/variable";

  .account-type-gray {
    color: #909090;
    background: #F6F6F6;
  }
</style>
